home *** CD-ROM | disk | FTP | other *** search
- Path: news.uni-stuttgart.de!news
- From: Markus Heller <Markus.Heller@studbox.uni-stuttgart.de>
- Newsgroups: comp.lang.c
- Subject: Combine zero-offset with unit-offset arrays ?
- Date: 4 Mar 1996 13:42:41 GMT
- Organization: Comp.Center (RUS), U of Stuttgart, FRG
- Message-ID: <4hes0h$52qi@info4.rus.uni-stuttgart.de>
- NNTP-Posting-Host: rusxppp168.rus.uni-stuttgart.de
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 1.12 (X11; I; Linux 1.2.13 i486)
- X-URL: news://news/comp.lang.c
-
- Hi,
-
- I want to combine my code (using zero-offset arrays) with
- code using unit-offset arrays.
- The FAQ - 2.16 mentions a method used "in old editions of
- Numerical Recipes in C" that leads to undefined behavior.
- Unfortunately there's no alternative mentioned.
- E.g.:
-
- void somefunction( float fa[], int n);
-
- int main(void)
- {
- float a[10]; /* zero offset: a[0] .. a[9] */
- int n=10;
-
- somefunction( a-1, 10 ); /* method suggested by Numerical Recipes,
- 2nd edition */
- }
-
- void somefunction( float fa[], int n)
- {
- /* do something with a, assuming unit-offset: a[1]..a[10] */
- }
-
-
- Which alternatives are possible to the above mentioned method ?
- (Is the method still leasding to undefined behavior ?)
-
- Markus
-
-